package com.api.shopapi.mapper;

import com.api.shopapi.entity.AskAnswerGroup;
import com.api.shopapi.entity.AskAnswerItem;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface AskAnswerItemMapper {


    @Insert("insert into ask_answer_item " +
            "(" +
            "AskAnswerItemCode," +
            "AskAnswerGroupCode," +
            "Fraction," +
            "Sort," +
            "Name" +
            ") " +
            "values " +
            "(" +
            "#{askAnswerItem.AskAnswerItemCode}," +
            "#{askAnswerItem.AskAnswerGroupCode}," +
            "#{askAnswerItem.Fraction}," +
            "#{askAnswerItem.Sort}," +
            "#{askAnswerItem.Name}" +
            ")" )
    int insert(@Param("askAnswerItem") AskAnswerItem askAnswerItem);


    @Delete("delete from ask_answer_item where askAnswerItemCode=#{askAnswerItemCode}")
    int delete(@Param("askAnswerItemCode") String askAnswerItemCode);


    @Update("update ask_answer_item set " +
            " Name=#{askAnswerItem.Name}," +
            " Fraction=#{askAnswerItem.Fraction}," +
            " Sort=#{askAnswerItem.Sort}," +
            " AskAnswerGroupCode=#{askAnswerItem.AskAnswerGroupCode}," +
            " where askAnswerItemCode=#{askAnswerItem.askAnswerItemCode}")
    int update(@Param("askAnswerItem") AskAnswerItem askAnswerItem);


    @Select("select * from ask_answer_item where askAnswerItemCode=#{askAnswerItemCode} limit 1")
    AskAnswerItem getByAskAnswerItemCode(@Param("askAnswerItemCode") String askAnswerItemCode);


    @Select("select * from ask_answer_item where askAnswerGroupCode=#{askAnswerGroupCode}")
    List<AskAnswerItem> ListByAskAnswerGroupCode(@Param("askAnswerGroupCode") String askAnswerGroupCode);



}
